<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 29795
  Date: 2025/3/26
  Time: 下午11:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table border="1">
    <tr>
        <th>id</th>
        <th colspan="2">deptname</th>
    </tr>
    <c:forEach var="dept" items="${depts}">
        <tr>
            <td>${dept.id}</td>
            <td>${dept.deptname}</td>
            <td><input value="删除" type="button" onclick="deleteDept(${dept.id})"></td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
<script>
    function deleteDept(id) {
        if(confirm('确定要删除此部门吗？')) {
            window.location.href = '/deleteDept?id=' + id;
        }
    }
</script>